package com.thkj.modules.check.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.thkj.modules.check.entity.TblReform;
import com.thkj.modules.check.service.TblCheckService;
import com.thkj.modules.check.service.TblReformService;

import cn.hutool.core.util.IdUtil;
import dp.R;
import dp.util.DateUtil;
import dp.web.BaseAction;

@RestController
@RequestMapping("/backstage/reform")
public class ReformAction extends BaseAction {
	@Autowired
	TblReformService tblReformService;

	@Autowired
	TblCheckService tblCheckService;

	@RequestMapping("")
	public ModelAndView index() {
		return new ModelAndView("reform/list");
	}

	/**
	 * 查询整改
	 * 
	 * @param checkId
	 * @return
	 */
	@RequestMapping("/query")
	public R query(String checkId) {
		List<Map> list = tblReformService.query(checkId);
		return R.success(list);
	}

	/**
	 * 编辑
	 * 
	 * @param refrom
	 * @return
	 */
	@RequestMapping("/edit")
	public R edit(TblReform refrom) {
		try {
			refrom.setId(IdUtil.objectId());
			refrom.setTime(DateUtil.getNowAsTimestamp());
			refrom.setType("2");
			tblReformService.insertTblReform(refrom);
		} catch (Exception e) {
			return R.failure(e.getMessage());
		}
		return R.SUCCESS;
	}
}